Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 28, 2025

实现微信小程序多端登录验证接口 code2VerifyInfo,用于手表端等多端登录场景。

官方文档:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/miniapp/openapi/code2Verifyinfo.html

变更内容

  • WxMaApiUrlConstants - 新增 CODE_2_VERIFY_INFO_URL 常量
  • WxMaCode2VerifyInfoResult - 新增返回结果类,包含 session_keyopenidunionidis_limit 字段
  • WxMaUserService - 新增 getCode2VerifyInfo(String code, String checkcode) 接口方法
  • WxMaUserServiceImpl - 实现接口调用逻辑

使用示例

WxMaCode2VerifyInfoResult result = wxMaService.getUserService()
    .getCode2VerifyInfo(code, checkcode);

String sessionKey = result.getSessionKey();
String openid = result.getOpenid();
Boolean isLimit = result.getIsLimit();
Original prompt

This section details on the original issue you should resolve

<issue_title>微信的多端登录有支持吗</issue_title>
<issue_description># 提问前,请确保阅读过项目首页说明以及wiki开发文档相关内容,完成内容后,请务必移除包括本句在内的无用内容,以免影响他人阅读,否则直接关闭,谢谢合作~

简要描述

登录接口官方出了一个多端的api,请问有计划支持吗

官方文档地址

请提供所需功能对应的微信官方文档地址以便进行确认。
https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/miniapp/openapi/code2Verifyinfo.html</issue_description>

Comments on the Issue (you are @copilot in this section)

@binarywang 如果有空的话,欢迎帮忙实现,看起来也挺简单,否则就只能等等了。 @binarywang 另外请规范发帖内容

Custom agent used: 全部用中文
需要用中文,包括PR标题和分析总结过程


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for multi-device login API feat: 添加微信小程序多端登录 code2VerifyInfo 接口支持 Nov 28, 2025
Copilot AI requested a review from binarywang November 28, 2025 14:08
Copilot finished work on behalf of binarywang November 28, 2025 14:08
@binarywang binarywang added this to the 4.8.0 milestone Dec 2, 2025
@binarywang binarywang marked this pull request as ready for review December 3, 2025 09:25
Copilot AI review requested due to automatic review settings December 3, 2025 09:25
@binarywang binarywang merged commit 5247627 into develop Dec 3, 2025
4 of 5 checks passed
@binarywang binarywang deleted the copilot/support-multi-device-login branch December 3, 2025 09:25
Copilot finished reviewing on behalf of binarywang December 3, 2025 09:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

本 PR 实现了微信小程序多端登录验证接口 code2VerifyInfo,用于支持手表端等多端登录场景。该实现遵循了 WxJava 项目的编码规范和架构模式,代码质量良好。

主要变更:

  • 新增 API 接口支持多端登录场景(手表端授权等)
  • 按照微信官方文档实现了完整的请求和响应处理
  • 遵循项目现有的代码组织和命名约定

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java 在 User 接口中新增 CODE_2_VERIFY_INFO_URL 常量,定义多端登录验证接口的 URL
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCode2VerifyInfoResult.java 新增响应结果类,包含 session_key、openid、unionid、is_limit 四个字段,使用 Lombok 注解和 Gson 序列化
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaUserService.java 在用户服务接口中新增 getCode2VerifyInfo 方法定义,包含完整的 Javadoc 文档和参数说明
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImpl.java 实现 getCode2VerifyInfo 方法,调用微信 API 并返回解析后的结果对象

Comment on lines +92 to +98
public WxMaCode2VerifyInfoResult getCode2VerifyInfo(String code, String checkcode) throws WxErrorException {
JsonObject param = new JsonObject();
param.addProperty("code", code);
param.addProperty("checkcode", checkcode);
String responseContent = this.service.post(CODE_2_VERIFY_INFO_URL, param.toString());
return WxMaCode2VerifyInfoResult.fromJson(responseContent);
}
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新增的 getCode2VerifyInfo 方法缺少相应的单元测试。建议在 WxMaUserServiceImplTest.java 中添加测试用例,可以参考同文件中 testGetPhoneInfo() 的测试模式。

示例测试方法:

@Test
public void testGetCode2VerifyInfo() throws WxErrorException {
  WxMaCode2VerifyInfoResult result = this.wxService.getUserService()
    .getCode2VerifyInfo("testCode", "testCheckcode");
  assertNotNull(result);
  System.out.println(result.toString());
}

Copilot uses AI. Check for mistakes.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

微信的多端登录有支持吗

2 participants